<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 定义按钮和输入框 -->
    <input type="text" name="" id="jsapi_exer05_exer05_text01">
    <button id="jsapi_exer05_html_button01">隐藏密码</button>
</body>
<script>
    //设置数据源
    let but=document.querySelector("#jsapi_exer05_html_button01");
    let text=document.querySelector("#jsapi_exer05_exer05_text01");
    //绑定事件类型
    but.onclick=function(){
        if(but.innerHTML.indexOf("隐藏密码")!=-1){
            text.type='password';
            but.innerHTML="显示密码";
        }
       else if(but.innerHTML.indexOf("显示密码")!=-1){
            text.type='text';
            but.innerHTML="隐藏密码";
        }
        else{
            alert("文本错误");
        }        

    }
</script>
</html>